﻿Imports Aricie.DNN.Modules.LuceneSearch.Business

Namespace Configuration.ContentManagement

    Public Class ContentProviderLibrary
        Implements IContentProviderLibrary

        Private Shared _instance As New ContentProviderLibrary
        Public Shared ReadOnly Property Instance As ContentProviderLibrary
            Get
                Return _instance
            End Get
        End Property


        Private Sub New()
        End Sub

        Public ReadOnly Property DetailedContentProviders As System.Collections.Generic.IEnumerable(Of ContentProviders.IContentProvider) Implements IContentProviderLibrary.DetailsContentProviders
            Get
                Dim results As New List(Of ContentProviders.IContentProvider)
                results.AddRange(Aricie.DNN.Modules.LuceneSearch.ModuleProviders.ProviderFactory.Instance.GetStandAlonesProviders() _
                            .Where(Function(lpc) lpc.Enabled) _
                            .Select(Of ContentProviders.IContentProvider)(Function(lpc) New ContentProviders.BasicContentProvider() With {.Name = lpc.Name, .DisplayName = "Provider " & lpc.FriendlyName}))
                results.AddRange(Aricie.DNN.Modules.LuceneSearch.ModuleProviders.ProviderFactory.Instance.GetProgressiveStandAlonesProviders() _
                            .Where(Function(lpc) lpc.Enabled) _
                            .Select(Of ContentProviders.IContentProvider)(Function(lpc) New ContentProviders.BasicContentProvider() With {.Name = lpc.Name, .DisplayName = "Provider " & lpc.FriendlyName}))
                Return results
            End Get
        End Property

        Public ReadOnly Property ContentProviders As System.Collections.Generic.IEnumerable(Of ContentProviders.IContentProvider) Implements IContentProviderLibrary.ContentProviders
            Get
                Dim results As New List(Of ContentProviders.IContentProvider)

                ' les modules
                results.AddRange(LuceneIndexer.GetSearchableDesktopModules(Aricie.DNN.Services.NukeHelper.PortalId).Select(Of ContentProviders.IContentProvider)(Function(dmi) New ContentProviders.BasicContentProvider() With {.Name = dmi.ModuleName, .DisplayName = "Module " & dmi.FriendlyName}))
                ' les providers
                results.AddRange(Aricie.DNN.Modules.LuceneSearch.ModuleProviders.ProviderFactory.Instance.GetStandAlonesProviders() _
                                 .Where(Function(lpc) lpc.Enabled) _
                                 .Select(Of ContentProviders.IContentProvider)(Function(lpc) New ContentProviders.BasicContentProvider() With {.Name = lpc.Name, .DisplayName = "Provider " & lpc.FriendlyName}))
                results.AddRange(Aricie.DNN.Modules.LuceneSearch.ModuleProviders.ProviderFactory.Instance.GetProgressiveStandAlonesProviders() _
                                 .Where(Function(lpc) lpc.Enabled) _
                                 .Select(Of ContentProviders.IContentProvider)(Function(lpc) New ContentProviders.BasicContentProvider() With {.Name = lpc.Name, .DisplayName = "Provider " & lpc.FriendlyName}))
                Return results
            End Get
        End Property
    End Class

End Namespace